let lineNumber = 1;
let pointNumber = 3

let data = [];
for (let i = 0; i < lineNumber; i++) {
    let data2 = [];
    for (let j = 0; j < pointNumber * 2; j++) {
        if (Math.random() < 0.5) {
            data2.push((-1) * Math.random());
        } else {
            data2.push(Math.random());
        }
    }
    data.push(data2);
}


const caculate = (x0, y0, x1, y1, solid, dasharray) => {
    let makedPoint = []
    let width = Math.sqrt((x1 - x0) * (x1 - x0) + (y1 - y0) * (y1 - y0));
    let division = Math.floor(width / dasharray);
    let multiple = width / dasharray;
    let vectorX = x1 - x0;
    let vectorY = y1 - y0;
    let vectorSolidX = (x1 - x0) * (1 / division) * (solid / dasharray);
    let vectorSolidY = (y1 - y0) * (1 / division) * (solid / dasharray);
    let multipleX = (x1 - x0) * (1 / division);
    let multipleY = (y1 - y0) * (1 / division);
    for (let i = 0; i <division - 1; i ++) {
        makedPoint.push([vectorX + multipleX * i, vectorY + multipleY * i, (vectorX + vectorSolidX) + multipleX * i, (vectorY + vectorSolidY) + multipleY * i])
    }
    return makedPoint;
}

const makeDashPoint = (solid, empty, data) => {
		console.log(data);

    let dasharray = solid + empty;
    let newPoint = []
    for (let i = 0, length = data.length; i < length; i++) {
        for (let j = 0, length1 = data[i].length; j < length1 - 2; j += 2) {
            newPoint = newPoint.concat(caculate(data[i][j], data[i][j + 1], data[i][j + 2], data[i][j + 3], solid, dasharray))
        }
    }
    return newPoint
}

makeDashPoint(0.005, 0.002, data)